package top.ucat.x.system.entity.beans.dictionary;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import top.ucat.x.system.entity.SysDictionaryContent;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Auther: Jun
 * @Date: 2019/9/10 12:06
 * @Description:
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DictionaryVo implements Serializable {

    private String id;
    private String type;
    private String description;
    private String remark;
    private List<DictionaryContentVo> contents;

    public static List getDictionaryContentsVos(List<SysDictionaryContent> list) {
        if (list != null) {
            return list.stream().map(sysDictionaryContent -> {
                DictionaryContentVo dicVo = new DictionaryContentVo();
                BeanUtils.copyProperties(sysDictionaryContent, dicVo);
                return dicVo;
            }).collect(Collectors.toList());
        }
        return new ArrayList();
    }
}
